/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package assignment2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * ProductList Class:
 * This class is separate from the Product class, but enables the Products and List of Products available to be modified
 * @author Vale
 *
 */
public class ProductList {

    private ArrayList<Product> prodList = new ArrayList<Product>();

    /**
     * void add(Product prod) Method:
     * Adds a Product (prod) to the Product List
     *
     */
    public void add(Product prod) {
        prodList.add(prod);
    }

    /**
     * void void remove(int index) Method:
     * Removes Product at index, from the Product List
     *
     */
    public void remove(int index) {
        prodList.remove(index);
    }

    /**
     * void remove(Product prod) Method:
     * Removes given Product (prod) from the Product List
     *
     */
    public void remove(Product prod) {
        prodList.remove(prod);
    }

    /**
     * boolean isEmpty() Method:
     * Checks if Product List is empty
     * @return True if empty, false otherwise
     *
     */
    public boolean isEmpty() {
        return prodList.isEmpty();
    }

    /**
     * int indexOf(Product prod) Method:
     * @param prod The product whose index is sought
     * @return Returns index of given Product
     *
     */
    public int indexOf(Product prod) {
        return prodList.indexOf(prod);
    }

    /**
     * int size() Method:
     * @return Returns Size of Product List
     *
     */
    public int size() {
        return prodList.size();
    }

    /**
     * Product get(int index) Method:
     * @param index The index of the Product
     * @return Returns Product from Product List at given index
     *
     */
    public Product get(int index) {
        return prodList.get(index);
    }

    /**
     * ArrayList<Product> getProdList() Method:
     * @return Returns List of Products
     *
     */
    public ArrayList<Product> getProdList() {
        return prodList;
    }

    /**
     * ProductList getProductListObject() Method:
     * @return Returns the entire ProductList object, to be used for other classes
     *
     */
    public ProductList getProductListObject() {
        return this;
    }

    /**
     * int getIndex(Product prod) Method:
     * @return Returns the index of a specified product
     *
     */
    public int getIndex(Product prod) {
        return prodList.indexOf(prod);
    }

    /**
     * void addProductAt(int index, Product prod) Method:
     * This method is used to add a specified product at a given index.
     *
     */
    public void addProductAt(int index, Product prod) {
        prodList.add(index, prod);
    }

}
